[SPARK-41793][SQL] Incorrect result for window frames defined by a range clause on large decimals#40138
Closed
ulysses-you wants to merge 2 commits intoapache:masterfrom
Closed
[SPARK-41793][SQL] Incorrect result for window frames defined by a range clause on large decimals#40138ulysses-you wants to merge 2 commits intoapache:masterfrom
ulysses-you wants to merge 2 commits intoapache:masterfrom
Conversation
Contributor
Author
cloud-fan
reviewed
Feb 23, 2023
| | (1, cast('11342371013783243717493546650944543.47' as decimal(38,2))), | ||
| | (1, cast('999999999999999999999999999999999999.99' as decimal(38,2))) | ||
| |as data(a, b); | ||
| |""".stripMargin) |
Contributor
There was a problem hiding this comment.
It seems simpler to use scala API for it
Seq(
1 -> "113...",
1 -> "999 ..."
).toDF("a", "b")
.select("a", $"b".cast("decimal(38, 2)"))
.createTempView("...")
cloud-fan
approved these changes
Feb 23, 2023
ef2692b to
fde25b1
Compare
Contributor
|
@ulysses-you to help other reviewers understand it, can you add more explaination in the PR description about how |
gerashegalov
approved these changes
Feb 23, 2023
Contributor
gerashegalov
left a comment
There was a problem hiding this comment.
LGTM
(verified that the failing spark-rapids test succeeds now)
Contributor
Author
|
@cloud-fan addressed, hope it is helpful |
Contributor
|
thanks, merging to master/3.4! |
cloud-fan
pushed a commit
that referenced
this pull request
Feb 23, 2023
…nge clause on large decimals ### What changes were proposed in this pull request? Use `DecimalAddNoOverflowCheck` instead of `Add` to craete bound ordering for window range frame ### Why are the changes needed? Before 3.4, the `Add` did not check overflow. Instead, we always wrapped `Add` with a `CheckOverflow`. After #36698, we make `Add` check overflow by itself. However, the bound ordering of window range frame uses `Add` to calculate the boundary that is used to determine which input row lies within the frame boundaries of an output row. Then the behavior is changed with an extra overflow check. Technically,We could allow an overflowing value if it is just an intermediate result. So this pr use `DecimalAddNoOverflowCheck` to replace the `Add` to restore the previous behavior. ### Does this PR introduce _any_ user-facing change? yes, restore the previous(before 3.4) behavior ### How was this patch tested? add test Closes #40138 from ulysses-you/SPARK-41793. Authored-by: ulysses-you <ulyssesyou18@gmail.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com> (cherry picked from commit fec4f7f) Signed-off-by: Wenchen Fan <wenchen@databricks.com>
gerashegalov
added a commit
to NVIDIA/spark-rapids
that referenced
this pull request
Feb 24, 2023
apache/spark#40138 fixed SPARK-41793, and Xfail is no longer necessary for 3.4+ Signed-off-by: Gera Shegalov <gera@apache.org>
snmvaughan
pushed a commit
to snmvaughan/spark
that referenced
this pull request
Jun 20, 2023
…nge clause on large decimals ### What changes were proposed in this pull request? Use `DecimalAddNoOverflowCheck` instead of `Add` to craete bound ordering for window range frame ### Why are the changes needed? Before 3.4, the `Add` did not check overflow. Instead, we always wrapped `Add` with a `CheckOverflow`. After apache#36698, we make `Add` check overflow by itself. However, the bound ordering of window range frame uses `Add` to calculate the boundary that is used to determine which input row lies within the frame boundaries of an output row. Then the behavior is changed with an extra overflow check. Technically,We could allow an overflowing value if it is just an intermediate result. So this pr use `DecimalAddNoOverflowCheck` to replace the `Add` to restore the previous behavior. ### Does this PR introduce _any_ user-facing change? yes, restore the previous(before 3.4) behavior ### How was this patch tested? add test Closes apache#40138 from ulysses-you/SPARK-41793. Authored-by: ulysses-you <ulyssesyou18@gmail.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com> (cherry picked from commit fec4f7f) Signed-off-by: Wenchen Fan <wenchen@databricks.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Use
DecimalAddNoOverflowCheckinstead ofAddto craete bound ordering for window range frameWhy are the changes needed?
Before 3.4, the
Adddid not check overflow. Instead, we always wrappedAddwith aCheckOverflow. After #36698, we makeAddcheck overflow by itself. However, the bound ordering of window range frame usesAddto calculate the boundary that is used to determine which input row lies within the frame boundaries of an output row. Then the behavior is changed with an extra overflow check.Technically,We could allow an overflowing value if it is just an intermediate result. So this pr use
DecimalAddNoOverflowCheckto replace theAddto restore the previous behavior.Does this PR introduce any user-facing change?
yes, restore the previous(before 3.4) behavior
How was this patch tested?
add test